Skip to content

Conversation

@eriawan
Copy link
Member

@eriawan eriawan commented Oct 14, 2025

Fixes #104716 by marking HttpClient.Send with UnsupportedOSPlatform with values of android, ios over eixisting.

Please review.

cc @wfurt , @ManickaP

Copilot AI review requested due to automatic review settings October 14, 2025 18:39
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Oct 14, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses issue #104716 by adding platform-specific annotations to mark HttpClient.Send methods as unsupported on Android and iOS platforms, in addition to the existing browser platform restriction.

Key changes:

  • Added UnsupportedOSPlatform attributes for "android" and "ios" to synchronous Send methods
  • Uncommented previously commented-out platform attributes in HttpClientHandler
  • Updated both implementation and reference assembly files for consistency

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
HttpMessageInvoker.cs Added android and ios platform restrictions to the base Send method
HttpClientHandler.AnyMobile.cs Uncommented android and ios platform attributes for the Send method override
HttpClient.cs Added android and ios platform restrictions to all four Send method overloads
System.Net.Http.cs Updated reference assembly to reflect the new platform restrictions
Comments suppressed due to low confidence (1)

src/libraries/System.Net.Http/ref/System.Net.Http.cs:1

  • Corrected malformed attribute name from 'UnsupportedOSPlatformAttributeUnsupportedOSPlatform' to 'UnsupportedOSPlatform'.
// Licensed to the .NET Foundation under one or more agreements.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

[System.Runtime.Versioning.UnsupportedOSPlatformAttribute("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("android")]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why it doens't also exclude "tvos"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ManickaP
Ok, good catch., thanks!
I will add "tvos" on the unsupportedOSPlatform today.

Copy link
Member Author

@eriawan eriawan Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ManickaP
Sorry for long reply. Done updating to add tvos.
Please review.

@karelz karelz changed the title Fixes #104716 marking HttpClient.Send with UnsupportedOSPlatform with values of android, ios over eixisting Fixes #104716 marking HttpClient.Send with UnsupportedOSPlatform with values of android, ios over existing Oct 29, 2025
@karelz karelz changed the title Fixes #104716 marking HttpClient.Send with UnsupportedOSPlatform with values of android, ios over existing Fixes #104716 marking HttpClient.Send with UnsupportedOSPlatform with values of Android, iOS over existing Oct 29, 2025
@karelz karelz changed the title Fixes #104716 marking HttpClient.Send with UnsupportedOSPlatform with values of Android, iOS over existing Mark HttpClient.Send tests with UnsupportedOSPlatform with values of Android, iOS over existing Oct 29, 2025
@karelz karelz added the test-enhancement Improvements of test source code label Oct 29, 2025
@karelz karelz changed the title Mark HttpClient.Send tests with UnsupportedOSPlatform with values of Android, iOS over existing Mark HttpClient.Send tests uniformly with UnsupportedOSPlatform for Android, iOS Oct 29, 2025
eriawan and others added 2 commits November 2, 2025 20:07
accept copilot suggestion to correct UnsupportedOSPlatform attribute name

Co-authored-by: Copilot <[email protected]>
@eriawan eriawan force-pushed the httpclient_send_add_unsupportedos_attributes branch from f910d01 to 5066cb7 Compare November 2, 2025 13:07
@eriawan
Copy link
Member Author

eriawan commented Nov 2, 2025

Rebase again to main branch as of now.

Copy link
Member

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@ManickaP
Copy link
Member

ManickaP commented Nov 3, 2025

Seems like the errors are relevant: API compatibility errors between 'ref/net10.0/System.Net.Http.dll' (left) and 'runtimes/win/lib/net10.0/System.Net.Http.dll' etc.

@eriawan
Copy link
Member Author

eriawan commented Nov 3, 2025

Seems like the errors are relevant: API compatibility errors between 'ref/net10.0/System.Net.Http.dll' (left) and 'runtimes/win/lib/net10.0/System.Net.Http.dll' etc.

@ManickaP
I think those errors are not caused by my PR, they are closely related to this issue on dotnet/arcade: dotnet/arcade#7585

especially this comment: dotnet/arcade#7585 (comment)
Now that ApiCompat has been moved to dotnet/sdk. the problem is still there: dotnet/sdk#35542

@ManickaP
Copy link
Member

ManickaP commented Nov 4, 2025

No, you have to add the same set of attributes to src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs as well.
This reproduces locally, so you can test it out yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Net.Http community-contribution Indicates that the PR has been added by a community member test-enhancement Improvements of test source code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HttpClient.Send not supported in MAUI running on Android or iOS causing PlatformNotSupportedException

3 participants